-
Notifications
You must be signed in to change notification settings - Fork 364
feat: Refactor LLM model zoo and add KV cache support #3527
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Dheeraj Peri <[email protected]>
@@ -0,0 +1,193 @@ | |||
import torch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we create a tests/py/tools/llm
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can. These tests helped me debug accuracy/functionality issues during the development. It would take some time to get them working in CI. I can add them as a part of cherry-pick PR after this. What do you think ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly LGTM. just some questions
@@ -837,6 +859,7 @@ def contains_metadata(gm: torch.fx.GraphModule) -> bool: | |||
continue | |||
submodule_node_dict[node.name] = node | |||
|
|||
preserve_module_specs(original_in_spec, original_out_spec, partitioned_module) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should set spec for partitioned_module
's children?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The spec for children is actually set by the partitioning. I'm only trying to preserve the output spec for the entire partitioned_module (It should be the same as original module unless we change it explicitly which is the case in KV caching)
from utils import export_llm | ||
|
||
|
||
def export_llm(model, inputs, min_seq_len=1, max_seq_len=16): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not directly call tools/llm/utils.py?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have to use sys.append to include the path to tools/llm/utils.py to do that. I wanted this example to be standalone so I just copied this function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same questions above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM only suggestion is moving tests into a tests subdirectory or into the tests directory. Is optional.
return timings | ||
|
||
|
||
def recordStats(backend, timings, precision, batch_size=1, compile_time_s=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super minor but everything else is snake case
Description
This PR redesigns our LLM model compilation, unifies it, fixes output mismatch and performance issues. This PR also implements KV caching using native TensorRT.
Fixes # (issue)
Type of change
Checklist: